package com.example.demo.enums;


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @author v-mazhiping.ea
 * @create 2019/4/17
 * @since 1.0.0
 */
public enum RoleEnum {


    /**
     *
     */
    ADMINISTER(1, "Analysis", "运维"),
    OWNER(2, "Owner", "Owner"),
    MANAGER(3, "bpa-3","管理者"),
    NONE(4, "none", "无"),
    ;

    private static final long serialVersionUID = -1;


    /**
     * 值
     */
    private final Integer value;

    private final String menuCode;

    /**
     * 中文显示
     */
    private final String msgZh;

    RoleEnum(final Integer value, final String menuCode, final String msgZh) {
        this.value = value;
        this.msgZh = msgZh;
        this.menuCode = menuCode;
    }

    @JsonCreator
    public static RoleEnum getByValue(Integer value) {
        RoleEnum[] tribeTypeEnums = values();
        for (RoleEnum tribeTypeEnum : tribeTypeEnums) {
            if (tribeTypeEnum.getValue().equals(value)) {
                return tribeTypeEnum;
            }
        }
        return null;
    }

    @JsonCreator
    public static RoleEnum getByMenuCode(String menuCode) {
        RoleEnum[] tribeTypeEnums = values();
        for (RoleEnum tribeTypeEnum : tribeTypeEnums) {
            if (tribeTypeEnum.getMenuCode().equals(menuCode)) {
                return tribeTypeEnum;
            }
        }
        return null;
    }

    public static String getMsgZh(Integer value) {
        RoleEnum[] enums = values();
        for (RoleEnum enumInfo : enums) {
            if (enumInfo.getValue().equals(value)) {
                return enumInfo.getMsgZh();
            }
        }
        return null;
    }

    public String getMsgZh() {
        return this.msgZh;
    }

    @JsonValue
    public Integer getValue() {
        return this.value;
    }

    public String getMenuCode() {
        return this.menuCode;
    }

}
